import Singleton from 'db://assets/Base/Singleton'
import { resources, SpriteFrame } from 'cc'
export default class ResourceManager extends Singleton {
  static get Instance() {
    return super.GetInstance<ResourceManager>()
  }

  loadDir(path: string, type: typeof SpriteFrame = SpriteFrame) {
    return new Promise<SpriteFrame[]>((resolve, reject) => {
      // 使用resources.loadDir方法加载资源，
      // 如果加载失败则调用reject，否则通过resolve返回加载的资源。
      resources.loadDir(path, type, function (err, assets) {
        if (err) {
          reject(err)
          return
        }
        resolve(assets)
      })
      //
    })
  }
}
